package com.crysta1.picviewer;

import android.view.GestureDetector;
import android.view.MotionEvent;

import com.github.chrisbanes.photoview.PhotoView;

    class CustomDoubleTapListener implements GestureDetector.OnDoubleTapListener {
        private final PhotoView photoView;

        public CustomDoubleTapListener(PhotoView photoView) {
            this.photoView = photoView;
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            float currentScale = photoView.getScale();
            float mediumScale = photoView.getMediumScale();
            float minScale = photoView.getMinimumScale();

            if (currentScale > minScale) {
                // 双击缩小到最小比例
                photoView.setScale(minScale, e.getX(), e.getY(), true);
            } else {
                // 双击放大到中等比例
                photoView.setScale(mediumScale, e.getX(), e.getY(), true);
            }
            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            return false;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            return false;
        }

}
